<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人中心 - 网盘系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary-color: #4361ee;
            --secondary-color: #3f37c9;
            --success-color: #4cc9f0;
            --light-bg: #f8f9fa;
            --border-color: #dee2e6;
            --text-color: #495057;
        }

        body {
            background-color: #f5f7fb;
            color: var(--text-color);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        .profile-container {
            max-width: 900px;
            margin: 2rem auto;
            background: white;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
            overflow: hidden;
        }

        .profile-header {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
            padding: 2.5rem 2rem;
            position: relative;
        }

        .avatar-container {
            position: relative;
            display: inline-block;
            margin-bottom: 1.5rem;
        }

        .avatar {
            width: 120px;
            height: 120px;
            border-radius: 50%;
            border: 4px solid rgba(255, 255, 255, 0.3);
            object-fit: cover;
            background-color: #e9ecef;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 3rem;
            color: var(--primary-color);
        }

        .avatar-edit {
            position: absolute;
            bottom: 10px;
            right: 10px;
            background: var(--success-color);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            cursor: pointer;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
        }

        .username {
            font-size: 1.8rem;
            font-weight: 600;
            margin-bottom: 0.25rem;
        }

        .user-email {
            font-size: 1.1rem;
            opacity: 0.9;
        }

        .profile-body {
            padding: 2.5rem;
        }

        .section-title {
            font-size: 1.4rem;
            font-weight: 600;
            color: var(--primary-color);
            margin-bottom: 1.5rem;
            padding-bottom: 0.75rem;
            border-bottom: 2px solid var(--border-color);
        }

        .form-label {
            font-weight: 500;
            margin-bottom: 0.5rem;
        }

        .form-control, .form-select {
            border-radius: 8px;
            padding: 0.75rem 1rem;
            border: 1px solid var(--border-color);
            transition: all 0.3s;
        }

        .form-control:focus, .form-select:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
        }

        .info-card {
            background: var(--light-bg);
            border-radius: 10px;
            padding: 1.5rem;
            margin-bottom: 1.5rem;
        }

        .info-item {
            display: flex;
            margin-bottom: 1rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        }

        .info-label {
            font-weight: 500;
            min-width: 150px;
            color: #6c757d;
        }

        .info-value {
            flex: 1;
        }

        .btn-primary {
            background: var(--primary-color);
            border: none;
            padding: 0.75rem 1.5rem;
            font-weight: 500;
            border-radius: 8px;
            transition: all 0.3s;
        }

        .btn-primary:hover {
            background: var(--secondary-color);
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
        }

        .alert {
            border-radius: 8px;
            padding: 1rem 1.5rem;
        }

        .stats-card {
            background: white;
            border-radius: 10px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            padding: 1.5rem;
            text-align: center;
            transition: transform 0.3s;
        }

        .stats-card:hover {
            transform: translateY(-5px);
        }

        .stats-number {
            font-size: 2rem;
            font-weight: 700;
            color: var(--primary-color);
            margin-bottom: 0.5rem;
        }

        .stats-label {
            font-size: 0.9rem;
            color: #6c757d;
        }
    </style>
</head>
<body>
<div class="profile-container">
    <!-- 头部区域 -->
    <div class="profile-header text-center">
        <div class="avatar-container">
            <div class="avatar">
                <i class="fas fa-user"></i>
            </div>
            <div class="avatar-edit">
                <i class="fas fa-camera"></i>
            </div>
        </div>
        <h1 class="username" th:text="${user.displayName ?: user.username}">用户昵称</h1>
        <p class="user-email" th:text="${user.email}">user@example.com</p>
    </div>

    <!-- 主体内容 -->
    <div class="profile-body">
        <!-- 成功/错误消息 -->
        <div th:if="${successMessage}" class="alert alert-success">
            <i class="fas fa-check-circle me-2"></i>
            <span th:text="${successMessage}">更新成功</span>
        </div>

        <div th:if="${errorMessage}" class="alert alert-danger">
            <i class="fas fa-exclamation-circle me-2"></i>
            <span th:text="${errorMessage}">错误消息</span>
        </div>

        <div class="row mb-4">
            <div class="col-md-3 mb-3">
                <div class="stats-card">
                    <div class="stats-number">128</div>
                    <div class="stats-label">文件总数</div>
                </div>
            </div>
            <div class="col-md-3 mb-3">
                <div class="stats-card">
                    <div class="stats-number">24.5</div>
                    <div class="stats-label">已用空间 (GB)</div>
                </div>
            </div>
            <div class="col-md-3 mb-3">
                <div class="stats-card">
                    <div class="stats-number">256</div>
                    <div class="stats-label">总空间 (GB)</div>
                </div>
            </div>
            <div class="col-md-3 mb-3">
                <div class="stats-card">
                    <div class="stats-number">89%</div>
                    <div class="stats-label">使用率</div>
                </div>
            </div>
        </div>

        <h3 class="section-title">个人信息</h3>

        <form th:action="@{/profile/update}" th:object="${updateRequest}" method="post">
            <div class="row mb-4">
                <div class="col-md-6 mb-3">
                    <label class="form-label">用户名</label>
                    <input type="text" class="form-control"
                           th:value="${user.username}" readonly>
                    <small class="form-text text-muted">用户名不可更改</small>
                </div>

                <div class="col-md-6 mb-3">
                    <label class="form-label">昵称</label>
                    <input type="text" class="form-control"
                           th:field="*{displayName}"
                           placeholder="请输入您的昵称">
                    <small class="text-danger" th:if="${#fields.hasErrors('displayName')}"
                           th:errors="*{displayName}">错误提示</small>
                </div>

                <div class="col-md-6 mb-3">
                    <label class="form-label">电子邮箱</label>
                    <input type="email" class="form-control"
                           th:field="*{email}"
                           placeholder="example@domain.com">
                    <small class="text-danger" th:if="${#fields.hasErrors('email')}"
                           th:errors="*{email}">错误提示</small>
                </div>

                <div class="col-md-6 mb-3">
                    <label class="form-label">手机号码</label>
                    <input type="tel" class="form-control"
                           th:field="*{phoneNumber}"
                           placeholder="请输入11位手机号码">
                    <small class="text-danger" th:if="${#fields.hasErrors('phoneNumber')}"
                           th:errors="*{phoneNumber}">错误提示</small>
                </div>
            </div>

            <div class="d-flex justify-content-end mt-4">
                <button type="submit" class="btn btn-primary">
                    <i class="fas fa-save me-2"></i>保存更改
                </button>
            </div>
        </form>

        <div class="mt-5">
            <h3 class="section-title">账户信息</h3>
            <div class="info-card">
                <div class="info-item">
                    <div class="info-label">注册时间</div>
                    <div class="info-value" th:text="${#temporals.format(user.createdAt, 'yyyy-MM-dd HH:mm')}">2023-01-01 10:00</div>
                </div>
                <div class="info-item">
                    <div class="info-label">最后更新</div>
                    <div class="info-value" th:text="${#temporals.format(user.lastUpdated, 'yyyy-MM-dd HH:mm')}">2023-06-15 14:30</div>
                </div>
                <div class="info-item">
                    <div class="info-label">账户状态</div>
                    <div class="info-value">
                        <span class="badge bg-success">正常使用</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
    // 简单的头像上传模拟
    document.querySelector('.avatar-edit').addEventListener('click', function() {
        alert('头像上传功能将在后续版本中开放');
    });

    // 表单提交前验证
    document.querySelector('form').addEventListener('submit', function(e) {
        const phoneInput = document.querySelector('input[name="phoneNumber"]');
        if (phoneInput.value && !/^1[3-9]\d{9}$/.test(phoneInput.value)) {
            alert('请输入有效的手机号码');
            e.preventDefault();
        }
    });
</script>
</body>
</html>